// 未登录前（没有token）的通用请求
import {
	requestURL
} from './config'
import  {getToken} from './auth.js'

function unloginRequest(data) {
	const input = data.data
	return new Promise((resolve, reject) => {
		uni.request({
			url: requestURL + data.url,
			data: input,  
			method: data.method,
			header: {
					'content-type': 'application/json',
					'Authorization': getToken() || ''
			},
			success: (res => {
			console.log(res);
			if (res.statusCode === 200) {
					console.log("成功200")
					resolve(res)
			} else {
					console.log("失败1")
					reject(res)
			}
		  }),
		  fail: (res => {
				console.log("失败2")
				reject(res)
		  })
		})
    })
}


export default function(data, url, method) {
	return unloginRequest(data, url, method)
}
